package cn.hxzy.mapper;

import cn.hxzy.domain.Chapter;
import cn.hxzy.domain.ClassMenu;
import cn.hxzy.domain.Course;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author LiDong
 * @Description
 * @create 2024/6/27 16:54
 */

public interface CourseMapper extends BaseMapper<Course> {

    /**
     * 根据课程名称模糊查询课程
     * @param searchName
     * @return
     */
    @Select("select * from sys_course where course_name like concat('%',#{searchName},'%')")
    List<Course> searchCourse(String searchName);


    /**
     * 给班级赋权
     * @return 影响行数
     */
    @Insert("insert into sys_class_menu(course_id,class_id) values (#{classMenu.courseId},#{classMenu.classId})")
    int addGrantClass(ClassMenu classMenu);

    /**
     * 根据班级编号获取课程编号
     * @param classId 班级编号
     * @return
     */
    @Select("SELECT course_id\n" +
            "FROM sys_class_menu\n" +
            "WHERE class_id=#{classId}")
    List<Integer> getCourseIdByClassId(Long classId);

}
